package set_map.leetcode;

import java.util.HashSet;
import java.util.Set;

/**
 * @author shkstart
 * @create 2022-11-01-22:15
 */
public class Num771 {
    public int numJewelsInStones(String jewels, String stones) {

        Set<Character> jewelSet = new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            jewelSet.add(jewels.charAt(i));
        }
        int ret = 0;
//        遍历石头，判断石头是否属于宝石
        for (int i = 0; i < stones.length(); i++) {
            if(jewelSet.contains(stones.charAt(i))){
                ret++;
            }

        }
        return ret;

    }
}
